package cn.personal.study.springbootdemo.domain.dto.mapper;

import cn.personal.study.springbootdemo.domain.Student;
import cn.personal.study.springbootdemo.domain.dto.request.CreateStudentRequestDTO;
import cn.personal.study.springbootdemo.domain.dto.response.CreateStudentResponseDTO;
import cn.personal.study.springbootdemo.domain.dto.response.UpdateStudentResponseDTO;

/**
 * 实体与请求响应DTO相互转换的mapper
 *
 * @author duliurui
 * @since 1.0.0
 */
public final class StudentMapper {
    public static Student createStudentRequestDTOToStudent(CreateStudentRequestDTO requestDTO) {
        Student student = new Student();
        student.setName(requestDTO.getName());
        student.setAge(requestDTO.getAge());
        return student;
    }

    public static CreateStudentResponseDTO studentToCreateStudentResponseDTO(Student student) {
        CreateStudentResponseDTO responseDTO = new CreateStudentResponseDTO();
        responseDTO.setName(student.getName());
        responseDTO.setAge(student.getAge());
        responseDTO.setId(student.getId());
        return responseDTO;
    }

    public static UpdateStudentResponseDTO studentToUpdateStudentResponseDTO(Student student) {
        UpdateStudentResponseDTO responseDTO = new UpdateStudentResponseDTO();
        responseDTO.setName(student.getName());
        responseDTO.setLoves(student.getLoves());
        responseDTO.setAge(student.getAge());
        responseDTO.setId(student.getId());
        return responseDTO;
    }
}
